package com.mall.db.domain;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.util.Date;

@Data
public class BaseEntity {

    @TableField(exist = false)
    private Integer pageCount = 1;

    @TableField(exist = false)
    private Integer limit = 10;

    @TableField(exist = false)
    private Integer page = 1;

    @TableField(exist = false)
    private Integer count = 0;

    /**
     * 创建时间
     */
    @JSONField(format = "yyyy-MM-dd ")
    private Date createTime;

    /**
     * 更新时间
     */

    private Date updateTime;

    public Date getCreateTime() {
        if(StringUtils.isEmpty(createTime)) return new Date();
        return createTime;
    }

    public Date getUpdateTime() {
        if(StringUtils.isEmpty(createTime)) return new Date();
        return updateTime;
    }
}
